package com.namuan.jp_stock.util;

import java.util.ArrayList;

import com.namuan.jp_stock.object.ShotActivity;
import com.namuan.jp_stock.object.Stock;
import com.namuan.jp_stock.object.Timestamp;
import com.namuan.jp_stock.R;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.RatingBar;
import android.widget.TextView;

public class StockItemAdapter extends ArrayAdapter<Stock> {
	private int mResource;
	private ArrayList<Stock> mList;
	private LayoutInflater mInflater;
	private Activity activity;
	public CustomImageManager imageManager;
	/**
	 * @param context
	 * @param layoutResource
	 * @param objects
	 */
	public StockItemAdapter(Activity a, int layoutResource, ArrayList<Stock> objects)
	{
		super(a, layoutResource, objects);
		this.activity =a;
		this.mResource = layoutResource;
		this.mList = objects;
		this.mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		imageManager = 
			new CustomImageManager(activity.getApplicationContext(),R.drawable.defaultuser);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.ArrayAdapter#getView(int, android.view.View,
	 * android.view.ViewGroup)
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		
		convertView = mInflater.inflate(mResource, null);
		TextView tvStockName = (TextView) convertView.findViewById(R.id.tvStockName);
		TextView tvStockNumber = (TextView) convertView.findViewById(R.id.tvStockNumber);
		Stock stock = mList.get(position);
		
		tvStockName.setText(stock.getStockname());
		tvStockNumber.setText(stock.getStocknumber());
		
		return convertView;
	}


	public class StockViewHolder {
	  public TextView tvStockName;
	  public TextView tvStockNumber;		
	}
}
